#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int is_leap(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
		return 1;
	return 0;
}
int main()
{
	int year, month, day;
	while ((scanf("%d%d", &year, &month)) != EOF)
	{
		switch (month)
		{
		case 1:
			day = 31;
			break;
		case 2:
			day = is_leap(year) ? 29 : 28;
			break;
		case 3:
			day = 31;
			break;
		case 4:
			day = 30;
			break;
		case 5:
			day = 31;
			break;
		case 6:
			day = 30;
			break;
		case 7:
			day = 31;
			break;
		case 8:
			day = 31;
			break;
		case 9:
			day = 30;
			break;
		case 10:
			day = 31;
			break;
		case 11:
			day = 30;
			break;
		case 12:
			day = 31;
			break;
		}
		printf("%d\n", day);
	}
	return 0;
}